package com.chiaching.framwork.core.handler.security;

import com.chiaching.framwork.domian.bean.SuperMallUserDetail;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author jiajing.he
 * @date 2021/7/27 上午10:39
 */
@Component
public class SuperMallUserDetailServiceImpl implements UserDetailsService {

    @Resource
    private SuperMallSecurityUserApi superMallSecurityUserApi;


    @Override
    public SuperMallUserDetail loadUserByUsername(String username) throws UsernameNotFoundException {
        return superMallSecurityUserApi.queryByUsername(username);
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        String encode = bCryptPasswordEncoder.encode("123");
        System.out.println(encode);
    }
}
